import { Tabs, Steps, Callout } from "nextra/components";
import UniversalTabs from "../../components/UniversalTabs";

# Hatchet Lite Deployment

To get up and running quickly, you can deploy via the `hatchet-lite` image. This image is designed for development and low-volume use-cases.

<Steps>

### Prerequisites

This deployment requires [Docker](https://docs.docker.com/engine/install/) installed locally to work.

### Getting Hatchet Lite Running

<Tabs items={['With Postgres (Default)', 'With Postgres + RabbitMQ']}>
  <Tabs.Tab>
To use Postgres as both your DB and message queue, copy the following `docker-compose.hatchet.yml` file to the root of your repository:

<Callout type="info">
  If you have an existing Postgres instance already running, you can simply
  point `DATABASE_URL` to that instance and ignore the `postgres` service
  deployment in the following docker-compose file.
</Callout>

```yaml filename="docker-compose.hatchet.yml" copy
version: "3.8"
name: hatchet-lite
services:
  postgres:
    image: postgres:15.6
    command: postgres -c 'max_connections=200'
    restart: always
    environment:
      - POSTGRES_USER=hatchet
      - POSTGRES_PASSWORD=hatchet
      - POSTGRES_DB=hatchet
    volumes:
      - hatchet_lite_postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -d hatchet -U hatchet"]
      interval: 10s
      timeout: 10s
      retries: 5
      start_period: 10s
  hatchet-lite:
    image: ghcr.io/hatchet-dev/hatchet/hatchet-lite:latest
    ports:
      - "8888:8888"
      - "7077:7077"
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      # Refer to https://docs.hatchet.run/self-hosting/configuration-options
      # for a list of all supported environment variables
      DATABASE_URL: "postgresql://hatchet:hatchet@postgres:5432/hatchet?sslmode=disable"
      SERVER_AUTH_COOKIE_DOMAIN: localhost
      SERVER_AUTH_COOKIE_INSECURE: "t"
      SERVER_GRPC_BIND_ADDRESS: "0.0.0.0"
      SERVER_GRPC_INSECURE: "t"
      SERVER_GRPC_BROADCAST_ADDRESS: localhost:7077
      SERVER_GRPC_PORT: "7077"
      SERVER_URL: http://localhost:8888
      SERVER_AUTH_SET_EMAIL_VERIFIED: "t"
      SERVER_DEFAULT_ENGINE_VERSION: "V1"
      SERVER_INTERNAL_CLIENT_INTERNAL_GRPC_BROADCAST_ADDRESS: localhost:7077
    volumes:
      - "hatchet_lite_config:/config"

volumes:
  hatchet_lite_postgres_data:
  hatchet_lite_config:
```

Then run `docker-compose -f docker-compose.hatchet.yml up` to get the Hatchet Lite instance running.

      </Tabs.Tab>
      <Tabs.Tab>

To use Postgres as your DB and RabbitMQ as the message queue, copy the following `docker-compose.hatchet.yml` file to the root of your repository:

<Callout type="info">
  If you have an existing Postgres instance already running, you can simply
  point `DATABASE_URL` to that instance and ignore the `postgres` service
  deployment in the following docker-compose file.
</Callout>

```yaml filename="docker-compose.hatchet.yml" copy
version: "3.8"
name: hatchet-lite
services:
  postgres:
    image: postgres:15.6
    command: postgres -c 'max_connections=200'
    restart: always
    environment:
      - POSTGRES_USER=hatchet
      - POSTGRES_PASSWORD=hatchet
      - POSTGRES_DB=hatchet
    volumes:
      - hatchet_lite_postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -d hatchet -U hatchet"]
      interval: 10s
      timeout: 10s
      retries: 5
      start_period: 10s
  rabbitmq:
    image: "rabbitmq:3-management"
    hostname: "rabbitmq"
    ports:
      - "5672:5672"
      - "15672:15672"
    environment:
      RABBITMQ_DEFAULT_USER: "user"
      RABBITMQ_DEFAULT_PASS: "password"
    volumes:
      - "hatchet_rabbitmq_data:/var/lib/rabbitmq"
      - "hatchet_rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf"
    healthcheck:
      test: ["CMD", "rabbitmqctl", "status"]
      interval: 30s
      timeout: 10s
      retries: 5
  hatchet-lite:
    image: ghcr.io/hatchet-dev/hatchet/hatchet-lite:latest
    ports:
      - "8888:8888"
      - "7077:7077"
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      SERVER_MSGQUEUE_KIND: rabbitmq
      SERVER_MSGQUEUE_RABBITMQ_URL: "amqp://user:password@rabbitmq:5672/"
      # Refer to https://docs.hatchet.run/self-hosting/configuration-options
      # for a list of all supported environment variables
      DATABASE_URL: "postgresql://hatchet:hatchet@postgres:5432/hatchet?sslmode=disable"
      SERVER_AUTH_COOKIE_DOMAIN: localhost
      SERVER_AUTH_COOKIE_INSECURE: "t"
      SERVER_GRPC_BIND_ADDRESS: "0.0.0.0"
      SERVER_GRPC_INSECURE: "t"
      SERVER_GRPC_BROADCAST_ADDRESS: localhost:7077
      SERVER_GRPC_PORT: "7077"
      SERVER_URL: http://localhost:8888
      SERVER_AUTH_SET_EMAIL_VERIFIED: "t"
      SERVER_DEFAULT_ENGINE_VERSION: "V1"
    volumes:
      - "hatchet_lite_config:/config"

volumes:
  hatchet_lite_postgres_data:
  hatchet_lite_config:
  hatchet_rabbitmq_data:
  hatchet_rabbitmq.conf:
```

Then run `docker-compose -f docker-compose.hatchet.yml up` to get the Hatchet Lite instance running.

      </Tabs.Tab>

</Tabs>

### Accessing Hatchet Lite

Once the Hatchet Lite instance is running, you can access the Hatchet Lite UI at [http://localhost:8888](http://localhost:8888).

By default, a user is created with the following credentials:

```
Email: admin@example.com
Password: Admin123!!
```

## Run tasks against the Hatchet instance

To run tasks against this instance, you will first need to create an API token for your worker. There are two ways to do this:

1. **Using a CLI command**:

   You can run the following command to create a token:

   ```sh
   docker compose -f docker-compose.hatchet.yml exec hatchet-lite /hatchet-admin token create --config /config --tenant-id 707d0855-80ab-4e1f-a156-f1c4546cbf52 | xargs
   ```

2. **Using the Hatchet dashboard**:
   - Log in to the Hatchet dashboard.
   - Navigate to the "Settings" page.
   - Click on the "API Tokens" tab.
   - Click on "Create API Token".

Now that you have an API token, see the guide [here](https://docs.hatchet.run/home/setup) for how to run your first task.

</Steps>
